package com.boot.security.server.service.impl.mffl.Lawyerservicepeoplenumber;

import com.boot.security.server.dao.mffl.MfflLawyerservicepeoplenumberDao;
import com.boot.security.server.dao.mffl.MfflUserDao;
import com.boot.security.server.model.SysUser;
import com.boot.security.server.model.mffl.MfflLawyerservicepeoplenumber;
import com.boot.security.server.model.mffl.MfflUser;
import com.boot.security.server.utils.UserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 律师服务人数业务
 */
@Service
public class LawyerservicepeoplenumberService {

    //服务人数表
    @Autowired
    private MfflLawyerservicepeoplenumberDao mfflLawyerservicepeoplenumberDao;

    /**
     * 查看律师服务人数
     */
    public MfflLawyerservicepeoplenumber showLawyerservicepeoplenumber(Integer Lawyerid){
        MfflLawyerservicepeoplenumber getlawyerservicepeoplenumber = mfflLawyerservicepeoplenumberDao.getlawyerservicepeoplenumber(Lawyerid);
        if(getlawyerservicepeoplenumber == null){
            MfflLawyerservicepeoplenumber m =  new MfflLawyerservicepeoplenumber();
            m.setNumber(0);
            return m;
        }
        return getlawyerservicepeoplenumber;
    }


    /**
     * 添加律师服务人数
     */
    public void increaseLawyerservicepeoplenumber(Integer Lawyerid){
        MfflLawyerservicepeoplenumber Lawyerservicepeoplenumber = mfflLawyerservicepeoplenumberDao.getlawyerservicepeoplenumber(Lawyerid);
        if(Lawyerservicepeoplenumber == null){
            MfflLawyerservicepeoplenumber mlpn = new MfflLawyerservicepeoplenumber();
            mlpn.setLawyerid(Lawyerid);
            mlpn.setNumber(1);
            Date date = new Date();
            mlpn.setCreateTime(date);
            mlpn.setUpdateTime(date);
            mlpn.setDeleteTime(date);
            mlpn.setDeleteState(1);
            mfflLawyerservicepeoplenumberDao.save(mlpn);
        }else{
            MfflLawyerservicepeoplenumber mlpn = new MfflLawyerservicepeoplenumber();
            mlpn.setId(Lawyerservicepeoplenumber.getId());
            mlpn.setNumber(Lawyerservicepeoplenumber.getNumber()+1);
            Date date = new Date();
            mlpn.setUpdateTime(date);
            mfflLawyerservicepeoplenumberDao.update(mlpn);
        }
    }
}
